<template>
  <div class="app-container">
    <el-table border v-loading="loading" :data="list">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="群组Id" align="center" prop="cardId"/>
      <el-table-column label="群组名字" align="center" prop="name"/>
      <el-table-column label="是否监听消息" align="center">
        <template slot-scope="scope">
<!--          <el-switch-->
<!--            v-model="scope.row.monitorMsg"-->
<!--            @change="monitorMsgChange(scope.row)"-->
<!--            active-color="#13ce66"-->
<!--            inactive-color="#ff4949">-->
<!--          </el-switch>-->
        </template>
      </el-table-column>
      <el-table-column label="当前顶置消息" align="center" prop="topMsg"/>
    </el-table>

    <pagination
      v-show="total>1"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>

import {getList, monitorMsg} from "@/api/bot/group";

export default {
  props: {
    botId: null,
  }, // 接收父组件传递的值
  data() {
    return {
      loading: true,
      list: [],
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        botId: undefined,
      }
    }
  },
  watch: {
    'botId'(newValue, oldValue) {
      this.getList();
    }
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true
      this.queryParams.botId = this.botId
      getList(this.queryParams).then(res => {
        this.list = res.records
        this.total = res.count
        this.loading = false
      }).catch(err => {
        this.msgError("查询数据失败");
        this.loading = false
      })
    },
    monitorMsgChange(row){
      console.log(row)
      monitorMsg()
    },
  },
}
</script>

<style scoped lang="scss">

</style>
